package drds.binlog.parse.inbound.group;

import drds.binlog.common.AbstractLifeCycle;
import drds.binlog.parse.EventParser;

import java.util.ArrayList;
import java.util.List;

/**
 * 组合多个EventParser进行合并处理，group只是做为一个delegate处理
 */
public class GroupEventParser extends AbstractLifeCycle implements EventParser
{

    private List<EventParser> eventParserList = new ArrayList<EventParser>();

    public void start()
    {
        super.start();
        // 统一启动
        for (EventParser eventParser : eventParserList)
        {
            if (!eventParser.isRunning())
            {
                eventParser.start();
            }
        }
    }

    public void stop()
    {
        super.stop();
        // 统一关闭
        for (EventParser eventParser : eventParserList)
        {
            if (eventParser.isRunning())
            {
                eventParser.stop();
            }
        }
    }


    public List<EventParser> getEventParserList()
    {
        return eventParserList;
    }

    public void setEventParserList(List<EventParser> eventParserList)
    {
        this.eventParserList = eventParserList;
    }

}
